import Http from '@/axios';

import { OrgForm, OrgQuery } from '@/model/org';

export default class OrgApi {
    public static insert(form: OrgForm) {
        return Http.post(this.handleUrl('insert'), form);
    }

    public static update(form: OrgForm) {
        return Http.post(this.handleUrl('update'), form);
    }

    public static delete(id: string) {
        return Http.post(this.handleUrl('delete'), { id });
    }

    public static pageList(query: OrgQuery) {
        return Http.get(this.handleUrl('list/page'), query);
    }

    public static info(id: string) {
        return Http.get(this.handleUrl('info'), { id });
    }

    public static listDictTree() {
        return Http.get(this.handleUrl('dict/tree'));
    }

    private static handleUrl(relativeUrl: string) {
        return 'api/sys/org/' + relativeUrl;
    }
}
